import logging
import os
import webapp2

from google.appengine.api import users
from google.appengine.ext.webapp import template
from tmpl import tmpl_util


def isDevMode(request):
  if (not request.params.has_key('compiled') and
      os.environ['SERVER_SOFTWARE'].startswith('Development')):
    return True
  return False


class InvalidUserPage(webapp2.RequestHandler):
  def get(self):
    user = users.get_current_user()
    if not user:
      self.redirect(users.create_login_url(self.request.uri))
      return

    self.response.out.write(
        tmpl_util.getInvalidUser(user, isDevMode(self.request)))


app = webapp2.WSGIApplication([
  ('/invaliduser', InvalidUserPage)
], debug=True)
